package globalCode;

import java.sql.Connection;
import java.util.SortedSet;
import java.util.TreeSet;

/*Subclass of GroupConnections used in the special case where the only connections needed 
 * to be analyzed are between a single user and the rest of the group.
 */
public class GroupToUserConnections extends GroupConnections {
	int userID; //The individual user within the group that all are analyzed against.
	
	public GroupToUserConnections(int gID, int uID, Connection c) {
		super(gID, c);
		userID = uID;
		calc();
	}
	
	//Where GC.java would compare every user to every other user, this only compares the given user to the rest (and returns it)
	@Override
	public SortedSet<UserConnection> getCons(){
		if(allCons != null)
			return allCons;
		SortedSet<UserConnection> cons = new TreeSet<UserConnection>();
		for(int i = 0; i<userIDs.size()-1; i++){
			if(userIDs.get(i)!=userID){
				UserConnection uc = new UserConnection(userIDs.get(i), userID, sqlCon);
				cons.add(uc);
			}
		}
		return cons;
	}

}
